	processor	6502
	seg	code

screen	= $06f8-120

	org	$0326
	dc.w	.start		; everyone has to start somewhere

	dc.b	$ed		; the weird guy from Maniac Mansion!

	; <hieroglyphs>
text	hex	ff c5 1a 64 91 f6 1d 4f 08 e4 04 c9 1f d6 39 22 4f
	hex	58 12 f6 1d 48 f8 1f f4 ce 89 79 cd 27 09 78 0b 5f
	hex	a7 62 36 78 f4 91 7f 08 e0 8c bc 06 8f 14 5c b5 cb
	hex	d2 63 9d 33 af 1f f2 3c 01 b1 13 f4 ce 79 cd 27 8e
	hex	09 78 88 31 e7 e1 1c 11 97 96 49 4b c1 fd 10 3d 0d
	hex	37 a6 74 4b c2 70 c9 e0 3c 11 9f a4 77 63 f1 91 52
	hex	7b 0e a7 a6 78 90 9e 9d 88 d9 e3 c8 6f e9 81 7f f2
	hex	3d 64 2d 7e 6b a7 e0 ba 67 24 7c 1a 4f 73 08 e6 93
	hex	c4 5c 89 eb 21 6b ff 91 e7 35 78 f5 80 90 7e 9b bd
	hex	22 13 c8 2f 91 e1 01 be 7d 24 7f 4c e8 82 4c 39 a3
	hex	f4 cf 12 13 c7 a3 47 12 0f fe
	; </hieroglyphs>

.wait	dc.b	$20		; this is some opcode which wastes some cycles
.start	sei
	tsx			; kind of magic! don't remove!

;	wait raster, soft scroll

	lda	#$bf		; this is real magic, it means Beyond Force!
.wr	cmp	$d012
	bne	.wr
	dcp	$d016		; do cryptic poke - Beyond Force magic in action
	bne	.wait		; magic failed :(

;	scroll screen data

.0	lda	screen+1,x	; gotta move somthing
	sta	screen,x
	lda	#7		; yellow or something
	sta	screen+$d328,x
	inx
	bne	.0		; we move a plenty!

	sta	$d016		; quite an incidence, it fits here too!

;	grab next 5 bits

	asl			; ancient shifting logic, A=0000 1110 afterwards
	sta	$d021		; another incidence, it looks nice on screen!

.1	ldy	text		; get next byte in buffer
	cpy	#$80		; and then do nothing useful with it!
				; (I wonder how short this routine would be
				;  without all these filler bytes?)

	ldx	#190		; something like this worked quite well back in 1988
.2	rol	text-1,x	; when I did sprite scroller so I put it here too
	dex
	bne	.2		; (honestly, I have no idea what it does!)

	rol			; half-engrish, should really be either ror or lol
	bcc	.1		; bad character code

;	output

	cmp	#$de		; we compare but do not branch! weird! (ed?)
	adc	#$41		; instead we add not-quite-42 (HHGttG *almost* rules)

	sta	screen+39	; we're running out of space, better to dump
	bcs	.wait		; something on screen and go back


;	that's it folks!
